package org.springframework.amqp.tutorials.config.topic;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitMessagingTemplate;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.time.Instant;
import java.util.UUID;

@Component
@Slf4j
public class TopicSender {
    @Autowired
    private RabbitMessagingTemplate rabbitTemplate;

    public String topicSendMsgToStudent() {
        String message = "给学生的消息发送成功，时间为：" + Instant.now().toString();
        rabbitTemplate.convertAndSend("myTopicExchange", "people.student", message);
        return "ok，发送成功";
    }

    public String topicSendMsgToTeacher() {
        String messgae = "给全部人的消息发送成功，时间为：" + Instant.now().toString();
        rabbitTemplate.convertAndSend("myTopicExchange", "people.teacher", messgae);
        return "ok,发送成功";
    }

}
